package com.article.controller;

import com.article.entity.ApiResult;
import com.article.entity.model.Article;
import com.article.entity.param.ArticleParam;
import com.article.service.ArticleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags = "文章相关接口")
@RequestMapping("/article")
public class ArticleController {

    @Autowired
    private ArticleService articleService;

    @ApiOperation(value = "添加文章", notes = "添加文章")
    @RequestMapping(value = "/addArticle")
    public ApiResult addArticle(@RequestBody Article param){
        ApiResult apiResult = articleService.addArticle(param);
        return apiResult;
    }

    @ApiOperation(value = "删除文章(主键)", notes = "删除文章(主键)")
    @RequestMapping(value = "/deleteArticleById")
    public ApiResult deleteArticleById(@RequestBody Article param){
        ApiResult apiResult = articleService.deleteArticleById(param);
        return apiResult;
    }

    @ApiOperation(value = "更新文章(主键)",notes = "更新文章(主键)")
    @RequestMapping(value = "/updateArticleById")
    public ApiResult updateArticleById(@RequestBody Article param){
        ApiResult apiResult = articleService.updateArticleById(param);
        return apiResult;
    }

    @ApiOperation(value = "查询文章(分页,多条件)", notes = "查询文章(分页,多条件)")
    @RequestMapping(value = "/selectArticleList")
    public ApiResult selectArticleList(@RequestBody ArticleParam param){
        ApiResult apiResult = articleService.selectArticleList(param);
        return apiResult;
    }
}

